# Contributor: Runar Tenfjord < runar dot tenfjord at gmail dot com >

_realname=pandas
pkgbase=mingw-w64-python-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python3-${_realname}"
pkgver=0.25.2
pkgrel=1
pkgdesc="Cross-section and time series data analysis toolkit (mingw-w64)"
arch=('any')
url="https://pandas.pydata.org/"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-numpy"
             "${MINGW_PACKAGE_PREFIX}-python3-pytz"
             "${MINGW_PACKAGE_PREFIX}-python3-dateutil"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-gcc")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/pandas-dev/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('ca91a19d1f0a280874a24dca44aadce42da7f3a7edb7e9ab7c7baad8febee2be')


prepare() {
  cp -a ${_realname}-${pkgver} ${_realname}-py3-${pkgver}
}

build() {
  # build for python3
  cd ${srcdir}/${_realname}-py3-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py build_ext --inplace

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py build
}

package() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-numpy"
           "${MINGW_PACKAGE_PREFIX}-python3-pytz"
           "${MINGW_PACKAGE_PREFIX}-python3-dateutil"
           "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
  optdepends=("${MINGW_PACKAGE_PREFIX}-python3-scipy: needed for miscellaneous statistical functions"
              "${MINGW_PACKAGE_PREFIX}-python3-matplotlib: needed for plotting"
              "${MINGW_PACKAGE_PREFIX}-python3-numexpr: needed for accelerating certain numerical operations (recommended)"
              "${MINGW_PACKAGE_PREFIX}-python3-openpyxl: needed for reading/writing Excel file")

  cd ${_realname}-py3-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --skip-build \
    --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  install -Dm644 LICENSE \
    "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}
